﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PInfoModel.Analyses
{
	public static class AnalyisSupport
	{
		public const string InfoHeader = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
		public const string InfoSubHeader = "++++++++++++++++++++++++++++++\n";
		public const string InfoTitle = "%%%%\n";

		public static void ComputeAndWriteStdAnalysisResults(CompleteAnalysisInfoForProgram pip, string methodoutputfile)
		{
			//call each method to compute the info
			GeneralAnalysisMetricsInfo generalinfo = GeneralAnalysisMetricsExtractor.ExtractGeneralInfo(pip);
			Tuple<CallGraphAnalysisInfo, CallGraphAnalysisInfo> cginfo = CallGraphAnalysisExtractor.ExtractCallGraphInfo(pip);
			
			//append all the info files 
			StringBuilder resb = new StringBuilder();
			resb.Append(generalinfo.EmitString());
			resb.Append(cginfo.Item1.EmitString());
			
			//write the results
			System.IO.File.WriteAllText(methodoutputfile, resb.ToString());
		}
	}
}
